#include <QSharedMemory>
#include <QThread>
#include <QDebug>
#include <QCoreApplication>
#include <iostream>
#include "csingleapplication.h"

int main(int argc, char *argv[])
{
    CSingleApplication a(argc, argv );

    if (a.isRunning())
    {
        std::string line;
        std::getline(std::cin, line);
        while (line != "exit")
        {
            a.sendMessage(QString::fromStdString(line));
            std::getline(std::cin, line);
        }
        return 0;
    }

    QObject::connect(&a, &CSingleApplication::messageAvailable, [=](QString message){
        qDebug() << message;
    });

    return a.exec();
}
